home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-04 | 3.4 KB | 129 lines | [TEXT/KAHL] |
- /********************************************************* DEFINITION
- DATE: 9/17/93
- AUTHOR: Eric R. Rosé
-
- CLASS: CPPScanZones
-
- SUPERCLASS: CPPPeriodicTask
-
- This c++ class goes through our list of zones, checking each
- for new Yenta nodes
-
- ********************************************************************/
-
- #include "CPPScanZones.h"
- #include <CPPTaskManager.h>
- #include <CPPStringList.h>
- #include "CPPZoneList.h"
- #include <CPPNode411.h>
- #include <StringTools.h>
-
- extern void ProcessNodeLookupResults (CPPObject *TheTask);
- extern CPPZoneList *gZoneList; // pointer to the send dialog's zone list
- extern void SetStatusMessage (StringPtr NewMessage, Boolean MakeCopy);
-
- extern StringPtr gAppName;
-
- /*-----------------------------------------------------------------*/
- /*------------------------ PUBLIC METHODS -------------------------*/
- /*-----------------------------------------------------------------*/
-
- CPPScanZones::CPPScanZones (CPPTaskManager *TaskManager,
- long minPeriod,
- Boolean deleteWhenDone) :
- CPPPeriodicTask (TaskManager, minPeriod,
- deleteWhenDone)
- {
- this->zoneList = NULL;
- this->lookupTask = NULL;
- this->whichZone = 0;
- }
-
- /*-----------------------------------------------------------------*/
-
- CPPScanZones::~CPPScanZones (void)
- {
- if (this->lookupTask)
- delete this->lookupTask;
- if (this->zoneList)
- {
- zoneList->DeleteItems(TRUE);
- delete this->zoneList;
- }
- }
-
- /*-----------------------------------------------------------------*/
-
- char *CPPScanZones::ClassName (void)
- {
- return "CPPScanZones";
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPScanZones::DoPeriodicAction (void)
- /* if the lookup has completed, advance to the next zone and */
- /* start another lookup */
- {
- StringPtr ZoneName;
- Str32 TypeStr;
- Str255 STemp;
-
- // call the inherited method to update frequency count
- CPPPeriodicTask::DoPeriodicAction();
-
- if (lookupTask->hasCompleted)
- {
- this->whichZone++;
- if (this->whichZone <= this->zoneList->GetNumItems())
- {
- ZoneName = (*zoneList)[this->whichZone];
- PStrCat (32, TypeStr, 2, "\pť", gAppName);
- lookupTask->StartNodeLookup("\p=", TypeStr, ZoneName, 50,
- ProcessNodeLookupResults);
- PStrCat (255, STemp, 3, "\pScanning zone '", ZoneName, "\p' for new users.");
- SetStatusMessage (STemp, TRUE);
- }
- else
- {
- this->hasCompleted = TRUE;
- this->callResult = noErr;
- }
- }
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPScanZones::DoCompletedAction (void)
- {
- CPPPeriodicTask::DoCompletedAction();
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPScanZones::StartScanZones (CompletionProc DoProc)
- {
- if (!this->hasCompleted)
- return;
-
- // get rid of the old lookup and zone data (if any)
- if (lookupTask)
- delete this->lookupTask;
- if (zoneList)
- delete this->zoneList;
-
- // get a list of all the zones
- this->zoneList = gZoneList->MakeListOfZones();
-
- // set up the lookup task
- this->lookupTask = new CPPNode411 (this->ourManager, 30, FALSE);
-
- // note that we haven't completed yet
- SetCompletionProc(DoProc);
- this->hasCompleted = FALSE;
- this->whichZone = 0;
-
- // add ourselves to the periodic task queue
- this->ourManager->AddPeriodicTask(this);
- }
-